file_prefix = "scvt_mesh.40962"

f = addfile(file_prefix + ".nc", "r")

nc = dimsizes(f->cell_lon)
ne = dimsizes(f->edge_lon)
deg = get_r2d("double")

wks = gsn_open_wks("pdf", file_prefix)

res_map = True
res_map@gsnFrame = False
; res_map@mpProjection = "satellite"
res_map@mpFillOn = False
res_map@mpOutlineOn = False
res_map@mpGridAndLimbOn = False
res_map@mpPerimOn = False
res_map@cnLinesOn = False
res_map@cnFillOn = True
res_map@cnFillPalette = "amwg256"
res_map@trGridType = "TriangularMesh"
res_map@sfXArray = f->cell_lon * deg
res_map@sfYArray = f->cell_lat * deg

radius2 = 6371229.0^2

printMinMax(f->cell_area * radius2, 0)

; map = gsn_csm_map(wks, res_map)
map = gsn_csm_contour_map(wks, f->cell_area * radius2, res_map)

; res_edge = True
; res_edge@gsLineColor = "black"

; lon = new(2, "double")
; lat = new(2, "double")

; do i = 0, ne - 1
;   j = f->vtx_of_edge(i,0) - 1
;   lon(0) = f->vtx_lon(j) * deg
;   lat(0) = f->vtx_lat(j) * deg
;   j = f->vtx_of_edge(i,1) - 1
;   lon(1) = f->vtx_lon(j) * deg
;   lat(1) = f->vtx_lat(j) * deg
;   gsn_polyline(wks, map, lon, lat, res_edge)
; end do

frame(wks)
